/*
 * KKModel.h
 *
 *  Created on: 2013-8-28
 *      Author: wh
 */

#ifndef KKModel_H_
#define KKModel_H_

#include "kaka_common.h"

class KKModel: public cocos2d::CCObject {
private:

	KKDictionary<std::string, CCString*>* m_properties;

	KKDictionary<std::string, KKModel*>* m_foreignValues;

	KKDictionary<std::string, KKMutableArray<KKModel*>*>* m_foreignSets;

public:
	KKModel();
	virtual ~KKModel();

	KKOBJECT_CREATE_METHOD(KKModel)
	;

	bool getBooleanProperty(std::string key, bool defaultValue = false);

	int getIntProperty(std::string key, int defaultValue = 0);

	float getFloatProperty(std::string key, float defaultValue = 0);

	std::string getstringProperty(std::string key,
			const char* defaultValue = "");

	KKModel* getForeignValue(std::string key);

	KKMutableArray<KKModel*>* getForeignSet(std::string key);

	void setProperty(std::string key, float value);

	void setProperty(std::string key, bool value);

	void setProperty(std::string key, const char* value);

	void setProperty(std::string key, int value);

	void setForeignValue(std::string key, KKModel* value);

	void setForeignSet(std::string key, KKMutableArray<KKModel*>* value);

};

typedef KKMutableArray<KKModel*> KKModelList;

#define KKMODELLIST_FOREACH(objects,child) \
		for(KKModelList::CCMutableArrayIterator it = objects->begin();it!=objects->end()&&(child=*it);it++)

#endif /* KKModel_H_ */
